Current Location: Blog >
Vietnam Cloud Server
1. Evaluate and select suppliers (Step 1: Quantify requirements).
- Evaluation metrics: daily active UV, concurrent QPS, peak PV, payment TPS, average latency per request (ms).- Practical steps: Use historical data (logs/GA) to multiply the peak value by a redundancy factor of 1.5~2 to obtain CPU, memory, bandwidth requirements, and disk IOPS targets.
- Example: If peak concurrency is 5000, it is recommended to pre-provide the basic application layer with 8 cores (16GB), the cache layer with 2 standalone 4-core 8GB Redis instances, and the main database with 16 cores (32GB) or managed instances.
2. Selecting data center locations and vendors in Vietnam (delays and compliance).
- Recommended: Vietnam local operators (such as VNPT, Viettel, FPT) or Asia-Pacific neighbors (Singapore, Hong Kong) as alternatives.- Practical steps: Use ping/traceroute to measure latency; Speedtest is used to measure upstream/downlink bandwidth; Confirm whether the provider supports local payments and legal compliance (data sovereignty).
- Recommendation: The main station should be located in the Vietnam data center, and the backup or CDN should use a Singapore node to balance latency and stability.
3. Architectural patterns (layering and redundancy).
- Architecture Key Points: Front-end CDN + LB (load balancing) + Application layer (container or virtual machine) + Caching layer (Redis/Memcached) + Database (master/slave/shard) + file storage.- Practical steps: deploy at least 2 application instances in different availability zones; The database adopts master-slave or managed read-write separation; Enable automatic backup and snapshots.
- Note: For finance/payment interfaces, it is recommended to use multi-active + offsite redundancy and record SLAs and RPO/RTO.
4. Automatic capacity expansion (detailed configuration example).
- Principle: Throttling is triggered based on CPU/number of requests/queue length.- Kubernetes Practice: Deploy HPA HorizontalPodAutoscaler, for example:
kubectl apply -f - <
kind: HorizontalPodAutoscaler
metadata: {name: webshop-hpa}
spec:
scaleTargetRef: {apiVersion: apps/v1, kind: Deployment, name: webshop}
minReplicas: 3
maxReplicas: 20
metrics: [{type: Resource, resource:{name: cpu, target:{type: Utilization, averageUtilization: 60}}}]
EOF
- Virtual machine/cloud hosting: Using the Cloud Provider's ASG/Auto Scaling group, threshold configuration of CPU >60% or Network >80% triggers capacity scaling.
5. Caching and CDN strategies (reducing backend pressure).
- Frontend: Deploy a CDN (Cloudflare or local vendor), cache static resources, and enable page caching rules.- Backend: Redis is used for hotspot caching, product detail caching, and rate limiting counters; Configure TTL and secondary recovery.
- Practical command: Common Redis configuration
redis.conf: maxmemory 4gb, maxmemory-policy allkeys-lru
Startup check: redis-cli info memory
6. Database Expansion and Optimization (Steps and Indexing Strategies).
- Steps: 1) Concentrate write pressure in the main library to share query load on the read-copy copy; 2) Sub-table the hotspot table (by month or by user ID); 3) Indexing queries and regularly analyzing slow queries.- Practical: MySQL example enabling replication: In the main database my.cnf, enable server-id and log-bin, execute CHANGE MASTER ON THE SLAVE database, and start the slave.
- Performance tools: Use pt-query-digest to analyze slow queries and optimize SQL.
7. Stress testing and capacity validation (tools and processes).
- Tools: k6, JMeter, Locust. K6 scripted testing is recommended and run concurrently in distributed local/cloud environments.- Practical Example (K6): k6 run -- VUS 500 -- duration 5m script.js; Monitor backend CPU/memory and 95/99 latency indicators.
- Validation points: zero error rates, average response times within acceptable ranges, slow database queries without surge, cache hit rate above 70%.
8. Monitoring and alerting (key metrics and configurations).
- Metrics: Application TPS, request latency P95/P99, error rate, CPU/memory, number of DB connections, Redis hit rate, queue length.- Practical operation: deploy Prometheus+Grafana, use NodeExporter to collect host metrics, and configure alert rules with AlertManager (e.g., p95> 1s to trigger 2-minute alerts).
- Execution steps: Install Prometheus, import template dashboards, configure email/DingTalk/Webhook in AlertManager.
9. Safety and Disaster Recovery (Practical Setup).
- Security: deploy WAF, configure HTTPS forced jumps, limit admin panel IPs, use API signatures and rate limits.- Disaster Recovery: Backing up database snapshots off-site (daily/hourly differential backups), configuring cross-region read-only replicas, and regularly rehearsing switching processes.
- Operation command example: mysqldump timed full backup and upload object storage, or use cloud vendor hosted backup features.